package com.icinfo.cloud.provider.peripheralinterface.taskcenter.controller;

import com.icinfo.cloud.common.security.util.UserUtil;
import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.common.utils.HeaderUtil;
import com.icinfo.cloud.provider.peripheralinterface.taskcenter.dto.DisposalBackResultDto;
import com.icinfo.cloud.provider.peripheralinterface.taskcenter.dto.TransferConfigureQueryDto;
import com.icinfo.cloud.provider.peripheralinterface.taskcenter.dto.TripartiteStatusDto;
import com.icinfo.cloud.provider.peripheralinterface.taskcenter.service.ITaskCenterService;
import com.icinfo.cloud.provider.peripheralinterface.taskcenter.vo.TransferConfigureVo;
import com.icinfo.cloud.xzcf.provider.member.userinfo.dto.UserDTO;
import com.icinfo.framework.common.web.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 描述：大综合一体化接口前端控制器
 *
 * @author zhengqiang
 * @date 2022-06-16 21:00
 */
@RestController
@RefreshScope
@RequestMapping("/peripheralInterface/taskCenter")
@Slf4j
public class TaskCenterInterfaceController {

    @Resource
    private ITaskCenterService taskCenterService;


    /**
     * 描述： 检查转处罚保存处置回传结果(检查)
     *
     * @author: zhengqiang
     * @date: 2022/8/16
     * @param: dto
     * @return {@link Result< String>}
     **/
    @PostMapping("/saveDisposalBackResult")
    public Result<String> saveDisposalBackResult(@RequestBody @Validated DisposalBackResultDto dto) {
        return taskCenterService.saveDisposalBackResult(dto);
    }

    /**
     * 【V1.4.1】描述： 修改协同的案件移送状态(协同)
     *
     * @author: zhengqiang
     * @date: 2022/8/22
     * @param: dto
     * @return {@link Result< String>}
     **/
    @PostMapping("/tripartiteStatusByRelUid")
    public Result<String> tripartiteStatusByRelUid(@RequestBody @Validated TripartiteStatusDto dto) {
        return taskCenterService.tripartiteStatusByRelUid(dto);
    }

    /**
     * 【V1.4.1】描述： 获取证据材料列表(协同)
     *
     * @author: zhengqiang
     * @date: 2022/8/22
     * @param: dto
     * @return {@link Result< String>}
     **/
    @PostMapping("/getTransferCaseEvidenceBy")
    public Result<TransferConfigureVo> getTransferCaseEvidenceBy(@RequestBody TransferConfigureQueryDto dto) {
        TransferConfigureVo transferCaseEvidenceBy = taskCenterService.getTransferCaseEvidenceBy(dto);
        return Result.success(Constant.STRING_SUCCESS_EN, transferCaseEvidenceBy);
    }

    /**
     * 描述： 设置签名(执法平台)
     *
     * @author: zhengqiang
     * @date: 2022/9/5
     * @param: ossPath
     * @return {@link Result}
     **/
    @GetMapping("/saveUserSignToTaskCenter")
    public Result saveUserSignToTaskCenter(@RequestParam("ossPath") String ossPath) {
        Map<String, String> stringStringMap = HeaderUtil.headerInfo();
        UserDTO userInfo = UserUtil.getUserInfo();
        Result result = taskCenterService.saveUserSign(ossPath, stringStringMap, userInfo.getRealName());
        return result;
    }
}
